let modules = import.meta.glob('../pages/**/*.vue');
import Layout from "@/layout/layout.vue";

// 接口菜单 菜单字符串映射本地vue文件
export function handleDynamicRoutes(routes = []) {
    const res = []
    routes.forEach(item => {
        if (item.component) {
            if (item.component === "Layout") {
                item.component = Layout;
            } else {
                item.component = modules[`../pages/${item.component}.vue`];
            }
        }
        if (item.children && item.children.length) {
            item.children = handleDynamicRoutes(item.children);
        }
        res.push(item);
    });
    return res;
}